package com.weetop.cfw.api

import com.weetop.cfw.bean.*
import com.weetop.cfw.constants.Constants
import com.weetop.cfw.utils.MMKVUtils
import io.reactivex.Observable
import okhttp3.MultipartBody
import retrofit2.http.*

interface Api {

    /**
     * 获取验证码
     */
    @FormUrlEncoded
    @POST("API/getsms.ashx")
    fun getVerificationCode(@Field("mobile") mobile: String): Observable<VerificationCodeBean>

    /**
     * 注册
     */
    @FormUrlEncoded
    @POST("API/reguser.ashx")
    fun registerUser(
        @Field("username") username: String, @Field("userpwd") userpwd: String, @Field(
            "mobile"
        ) mobile: String, @Field("Smscode") Smscode: String, @Field("utype") utype: Int
    ): Observable<RegisterBean>

    /**
     * 找回密码
     */
    @FormUrlEncoded
    @POST("API/resetpwd.ashx")
    fun forgetPassword(
        @Field("mobile") mobile: String,
        @Field("userpwd") userpwd: String,
        @Field("smscode") smscode: String
    ): Observable<ErrorBean>

    /**
     * 密码登录
     */
    @FormUrlEncoded
    @POST("API/loginuser.ashx")
    fun passwordLogIn(
        @Field("username") username: String,
        @Field("userpwd") userpwd: String
    ): Observable<LogInBean>

    /**
     * 类型
     */
    @FormUrlEncoded
    @POST("API/getbinfo.ashx")
    fun kind(@Field("action") action: String = "type"): Observable<KindBean>

    /**
     * 面积
     */
    @FormUrlEncoded
    @POST("API/getbinfo.ashx")
    fun area(@Field("action") action: String = "area"): Observable<AreaBean>

    /**
     * 获取个人信息
     */
    @FormUrlEncoded
    @POST("API/getmyacinfo.ashx")
    fun getPersonalInfo(@Field("Token") token: String = MMKVUtils.getToken()): Observable<PersonalInfoBean>

    /**
     * 根据城市关键词获取分站信息
     */
    @FormUrlEncoded
    @POST("API/getsubbykey.ashx")
    fun getCityIdByCityName(@Field("Key") cityName: String): Observable<CityIdBean>

    /**
     * 区域
     */
    @FormUrlEncoded
    @POST("API/getsubarea.ashx")
    fun quYu(@Field("cityid") cityid: Int): Observable<SiteBean>

    /**
     * 获取所有分站列表数据
     */
    @POST("API/getsitebyprov.ashx")
    fun getAllSubSiteListData(): Observable<AllSubSiteListBean>

    /**
     * 我的出租出售信息数据
     */
    @FormUrlEncoded
    @POST("API/getmyrsinfo.ashx")
    fun getMyRentalSaleListData(@FieldMap queryMap: Map<String, String>): Observable<MyLeaseSaleInformationListBean>

    /**
     * 获取热门城市信息
     */
    @POST("API/gethotsite.ashx")
    fun getHotSitesData(): Observable<HotSitesBean>

    /**
     * 获取出租出售浏览记录
     */
    @POST("API/getviewhistory.ashx")
    @FormUrlEncoded
    fun getLeaseSaleBrowsingRecord(
        @Field("Token") Token: String, @Field("curpage") curpage: Int, @Field(
            "pagesize"
        ) pagesize: Int = 10
    ): Observable<LeaseSaleBrowsingRecordBean>

    /**
     * 获取音频浏览记录
     */
    @POST("API/getvmhistory.ashx")
    @FormUrlEncoded
    fun getAudioBrowsingRecord(
        @Field("Infover") Infover: Int = 9003,
        @Field("Token") Token: String = MMKVUtils.getToken(),
        @Field(
            "curpage"
        ) curpage: Int,
        @Field("pagesize") pagesize: Int = 10
    ): Observable<AudioVideoBrowsingRecordBean>

    /**
     * 获取视频浏览记录
     */
    @POST("API/getvmhistory.ashx")
    @FormUrlEncoded
    fun getVideoBrowsingRecord(
        @Field("Infover") Infover: Int = 9001,
        @Field("Token") Token: String = MMKVUtils.getToken(),
        @Field(
            "curpage"
        ) curpage: Int,
        @Field("pagesize") pagesize: Int = 10
    ): Observable<AudioVideoBrowsingRecordBean>


    /**
     * 获取音频分类筛选数据
     */
    @POST("API/getvclist.ashx")
    @FormUrlEncoded
    fun getAudioFilterData(@Field("Infover") Infover: Int = 9003): Observable<AudioVideoFilterBean>

    /**
     * 获取视频分类筛选数据
     */
    @POST("API/getvclist.ashx")
    @FormUrlEncoded
    fun getVideoFilterData(@Field("Infover") Infover: Int = 9001): Observable<AudioVideoFilterBean>

    /**
     * 获取音频列表数据
     */
    @FormUrlEncoded
    @POST("API/getvslist.ashx")
    fun getAudioListData(
        @Field("Infover") Infover: Int = 9003, @Field("classid") classid: Int, @Field(
            "Key"
        ) Key: String, @Field("curpage") curpage: Int, @Field("pagesize") pagesize: Int = 10
    ): Observable<AudioVideoBrowsingRecordBean>

    /**
     * 获取视频列表数据
     */
    @FormUrlEncoded
    @POST("API/getvslist.ashx")
    fun getVideoListData(
        @Field("Infover") Infover: Int = 9001, @Field("classid") classid: Int, @Field(
            "Key"
        ) Key: String, @Field("curpage") curpage: Int, @Field("pagesize") pagesize: Int = 10
    ): Observable<AudioVideoBrowsingRecordBean>

    /**
     * 获取音频详情
     */
    @FormUrlEncoded
    @POST("API/getvsdetail.ashx")
    fun getAudioFrequencyDetail(@Field("Infoid") Infoid: Int): Observable<AudioVideoDetailBean>

    /**
     * 获取视频详情
     */
    @FormUrlEncoded
    @POST("API/getvsdetail.ashx")
    fun getCloudCurriculumDetail(@Field("Infoid") Infoid: Int): Observable<AudioVideoDetailBean>

    /**
     * 获取视频购买状态
     */
    @FormUrlEncoded
    @POST("API/getuservsstate.ashx")
    fun getCourseDetailStatus(
        @Field("Infoid") Infoid: Int,
        @Field("Token") token: String = MMKVUtils.getToken()
    ): Observable<CourseBuyStatus>

    /**
     * 获取厂房列表
     */
    @FormUrlEncoded
    @POST("API/getrslist.ashx")
    fun getWorkshopWarehouseList(@FieldMap queryMap: Map<String, String>): Observable<WorkshopWarehouseListBean>

    /**
     * 获取厂房详情数据
     */
    @FormUrlEncoded
    @POST("API/getrsdetail.ashx")
    fun workshopWarehouseDetailData(@Field("infoid") infoid: Int): Observable<WorkshopWarehouseDetailBean>

    /**
     * 获取推荐音频
     */
    @FormUrlEncoded
    @POST("API/getvslistrem.ashx")
    fun getRecommendAudioData(
        @Field("Infover") Infover: Int = 9003, @Field("classid") classid: Int, @Field(
            "Topnum"
        ) Topnum: Int = 10
    ): Observable<RecommendAudioVideoBean>

    /**
     * 获取推荐视频
     */
    @FormUrlEncoded
    @POST("API/getvslistrem.ashx")
    fun getRecommendVideoData(
        @Field("Infover") Infover: Int = 9001, @Field("classid") classid: Int, @Field(
            "Topnum"
        ) Topnum: Int = 10
    ): Observable<RecommendAudioVideoBean>

    /**
     * 获取搜索结果
     */
    @FormUrlEncoded
    @POST("API/searchrslist.ashx")
    fun getSearchResultData(@FieldMap queryMap: Map<String, String>): Observable<WorkshopWarehouseSearchResultBean>

    /**
     * 厂房详情猜你喜欢数据
     */
    @FormUrlEncoded
    @POST("API/getrsrel.ashx")
    fun getRecommendWorkshopWareHouseData(
        @Field("siteid") siteid: Int = Constants.siteId,
        @Field("intid") intid: Int = Constants.workshopIntId,
        @Field(
            "areaid"
        ) areaid: Int = Constants.workshopAreaId
    ): Observable<LeaseSaleBrowsingRecordBean>

    /**
     * 获取所有分站数据
     */
    @POST("API/getsubsite.ashx")
    fun getAllSitesData(): Observable<AllSitesBean>

    /**
     * 发布出租出售
     */
    @FormUrlEncoded
    @POST("API/savesubrsinfo.ashx")
    fun publishLeaseSaleInformation(@FieldMap publishMap: HashMap<String, String>): Observable<PublishBean>


    /**
     * 投诉举报
     */
    @FormUrlEncoded
    @POST("API/addQSBack.ashx")
    fun infoSuggest(
        @Field("infoid") infoid: String,
        @Field("Title") Title: String,
        @Field("Reason") Reason: String
    ): Observable<ErrorBean>

    /**
     * 更新用户头像
     */
    @Multipart
    @POST("API/updateuserface.ashx")
    fun uploadUserHeadImg(
        @Part token: MultipartBody.Part = MultipartBody.Part.createFormData(
            "Token",
            MMKVUtils.getToken()
        ), @Part multipartFile: MultipartBody.Part
    ): Observable<UploadUserHeadImgBean>

    /**
     * 上传用户浏览租售的记录
     */
    @FormUrlEncoded
    @POST("API/statviewlog.ashx")
    fun uploadUserRentSaleBrowseRecordData(
        @Field("Token") Token: String = MMKVUtils.getToken(), @Field(
            "Infoid"
        ) infoid: String
    ): Observable<ErrorBean>

    /**
     * 上传用户音视频浏览记录
     */
    @POST("API/statviewmlog.ashx")
    @FormUrlEncoded
    fun uploadUserAudioAndVideoBrowsingRecordsData(
        @Field("Token") token: String = MMKVUtils.getToken(), @Field(
            "Infoid"
        ) infoid: String
    ): Observable<ErrorBean>

    /**
     * 更新用户信息
     */
    @POST("API/updateuserinfo.ashx")
    @FormUrlEncoded
    fun updateUserInfo(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("Nickname") nickName: String,
        @Field(
            "Name"
        ) name: String,
        @Field("Gender") gender: String,
        @Field("Email") email: String,
        @Field("Company") company: String
    ): Observable<ErrorBean>

    /**
     * 清空厂房仓库租售浏览记录
     */
    @POST("API/clearviewlog.ashx")
    @FormUrlEncoded
    fun clearBrowseRecordList(
        @Field("Type") Type: Int,
        @Field("Token") Token: String = MMKVUtils.getToken()
    ): Observable<ErrorBean>

    /**
     * 通用代码表信息
     */
    @POST("API/getcodeinfo.ashx")
    @FormUrlEncoded
    fun generalCodeTable(@Field("Cateid") cateId: Int): Observable<GeneralCodeTableBean>

    /**
     * 根据分站ID获取出租的价格单位
     */
    @POST("API/getsitepunit.ashx")
    @FormUrlEncoded
    fun getPriceUnitBtSite(@Field("Siteid") siteId: Int): Observable<PriceUnitBean>

    /**
     * 上传图片
     */
    @POST("API/uploadimage.ashx")
    @Multipart
    fun uploadImage(
        @Part token: MultipartBody.Part = MultipartBody.Part.createFormData(
            "Token",
            MMKVUtils.getToken()
        ), @Part multipartFile: MultipartBody.Part
    ): Observable<UploadImageBean>

    /**
     * APP相关单页面
     */
    @POST("API/getappcon.ashx")
    @FormUrlEncoded
    fun getAppRelativeSinglePageIntroduce(@Field("qfile") qfile: String): Observable<SinglePageIntroduceBean>

    /**
     * 获取消息列表
     */
    @POST("API/getmymsglist.ashx")
    @FormUrlEncoded
    fun getMessageList(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("msgcate") msgcate: String,
        @Field(
            "curpage"
        ) curpage: Int,
        @Field("pagesize") pagesize: Int = 10
    ): Observable<MessageListBean>

    /**
     * 获取消息详情
     */
    @POST("API/getmymsginfo.ashx")
    @FormUrlEncoded
    fun getMessageDetailData(
        @Field("Token") Token: String = MMKVUtils.getToken(),
        @Field("msgid") msgid: Int
    ): Observable<MessageDetailBean>

    /**
     * 意见反馈
     */
    @POST("API/saveadvise.ashx")
    @FormUrlEncoded
    fun feedback(
        @Field("Content") content: String,
        @Field("Imglist") Imglist: String,
        @Field("Token") Token: String = MMKVUtils.getToken()
    ): Observable<ErrorBean>

    /**
     * 首页广告图
     */
    @POST("API/getindexadv.ashx")
    @FormUrlEncoded
    fun getAdvertisementData(
        @Field("Siteid") siteId: Int = Constants.siteId, @Field("Adpos") adpos: Int, @Field(
            "curpage"
        ) curpage: Int, @Field("pagesize") pagesize: Int = 10
    ): Observable<AdvertisementBean>

    /**
     * 首页广告图 修改
     */
    @POST("API/getindexadvEx.ashx")
    @FormUrlEncoded
    fun getAdvertisementExData(
        @Field("Siteid") siteId: Int = Constants.siteId,
        @Field("Adpos") adpos: Int,
        @Field("curpage") curpage: Int,
        @Field("pagesize") pagesize: Int = 10
    ): Observable<AdvertisementBean>

    /**
     * 首页推荐列表
     */
    @POST("API/getrefinlist.ashx")
    @FormUrlEncoded
    fun getRecommendActivitiesList(
        @Field("Siteid") siteId: Int = Constants.siteId,
        @Field("Adpos") adpos: Int,
        @Field("curpage") curpage: Int,
        @Field("pagesize") pagesize: Int = 10,
        @Field("topnum") topnum: Int = 10,
        @Field("classid") classid: Int = 0
    ): Observable<AdvertisementBean>

    /**
     * 首页推荐列表
     */
    @POST("API/getindexadvEx.ashx")
    @FormUrlEncoded
    fun getRecommendActivitiesListEx(
        @Field("Siteid") siteId: Int = Constants.siteId,
        @Field("Adpos") adpos: Int,
        @Field("curpage") curpage: Int,
        @Field("pagesize") pagesize: Int = 10
    ): Observable<AdvertisementBean>

    /**
     * 首页推荐详情
     */
    @POST("API/getfindetail.ashx")
    @FormUrlEncoded
    fun getRecommendInfo(@Field("infoid") infoid: Int): Observable<HomeRecommendInfoBean>

    /**
     * 退出登录
     */
    @POST("API/logout.ashx")
    @FormUrlEncoded
    fun logOut(@Field("Token") Token: String = MMKVUtils.getToken()): Observable<ErrorBean>

    /**
     * 获取APP是否有新版本
     */
    @POST("API/getappversion.ashx")
    @FormUrlEncoded
    fun checkAppVersionInfo(@Field("Appver") Appver: Int): Observable<AppVersionBean>

    /**
     * 热门搜索数据
     */
    @POST("API/gethotkey.ashx")
    @FormUrlEncoded
    fun getPopularSearchData(@Field("type") type: String): Observable<PopularSearchBean>

    /**
     * 我购买的课程数据
     */
    @POST("API/getmyvslist.ashx")
    @FormUrlEncoded
    fun getMyCoursesList(
        @Field("Token") token: String = MMKVUtils.getToken(), @Field("Status") status: Int, @Field(
            "curpage"
        ) curpage: Int, @Field("pagesize") pagesize: Int = 10
    ): Observable<MyCoursesBean>

    /**
     * 获取订单信息
     */
    @POST("API/savetrainorder.ashx")
    @FormUrlEncoded
    fun getOrderId(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("Infoid") Infoid: Int
    ): Observable<OrderIdBean>

    /**
     * 获取订单支付参数
     */
    @POST("API/getorderpay.ashx")
    @FormUrlEncoded
    fun getOrderInfo(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("orderid") orderId: String
    ): Observable<OrderInfoBean>

    /**
     * 取消订单
     */
    @POST("API/canceltrainorder.ashx")
    @FormUrlEncoded
    fun cancelCourseOrder(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("orderid") orderId: String
    ): Observable<ErrorBean>


    /**
     * 获取指定广告价格
     */
    @POST("API/getapptopprice.ashx")
    @FormUrlEncoded
    fun getAdTopPrice(@Field("adid") adid: String = "25"): Observable<AdTopPriceBean>

    /**
     * 生成指定广告订单
     */
    @POST("API/saveapptoporder.ashx")
    @FormUrlEncoded
    fun getAdTopOrder(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("adid") adid: String = "25",
        @Field("infoid") infoid: String,
        @Field("Buym") Buym: Int,
        @Field("Note") Note: String
    ): Observable<OrderInfoBean>


    /**
     * 生成vip订单
     */
    @POST("API/savevieworder.ashx")
    @FormUrlEncoded
    fun getVipOrder(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("cfid") cfid: Int,
        @Field("infoid") infoid: String
    ): Observable<OrderInfoBean>


    /**
     * 获取vip套餐
     */
    @POST("API/getviewpaylist.ashx")
    @FormUrlEncoded
    fun getVipInfo(@Field("Token") token: String = MMKVUtils.getToken()): Observable<VipDataInfo>

    /**
     * 出租信息删除
     */
    @POST("API/delsubrsinfo.ashx")
    @FormUrlEncoded
    fun deleteInfo(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("Infoid") Infoid: Int
    ): Observable<ErrorBean>

    /**
     * 出租信息刷新
     */
    @POST("API/refrsinfodate.ashx")
    @FormUrlEncoded
    fun refreshInfo(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("Infoid") Infoid: Int
    ): Observable<ErrorBean>


    /**
     * 出租出售信息查看权限
     */
    @POST("API/getviewpower.ashx")
    @FormUrlEncoded
    fun checkPermission(
        @Field("Token") token: String = MMKVUtils.getToken(),
        @Field("Infoid") Infoid: Int
    ): Observable<PermisssionBean>


}